home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / s-valuti.ads < prev    next >
Text File  |  1996-01-30  |  5KB  |  86 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --                      S Y S T E M . V A L _ U T I L                       --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.6 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- The GNAT library is free software; you can redistribute it and/or modify --
  14. -- it under terms of the GNU Library General Public License as published by --
  15. -- the Free Software  Foundation; either version 2, or (at your option) any --
  16. -- later version.  The GNAT library is distributed in the hope that it will --
  17. -- be useful, but WITHOUT ANY WARRANTY;  without even  the implied warranty --
  18. -- of MERCHANTABILITY  or  FITNESS FOR  A PARTICULAR PURPOSE.  See the  GNU --
  19. -- Library  General  Public  License for  more  details.  You  should  have --
  20. -- received  a copy of the GNU  Library  General Public License  along with --
  21. -- the GNAT library;  see the file  COPYING.LIB.  If not, write to the Free --
  22. -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.        --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. --  This package provides some common utilities used by the s-valxxx files
  27.  
  28. package System.Val_Util is
  29. pragma Pure (Val_Util);
  30.  
  31.    procedure Normalize_String
  32.      (S    : in out String;
  33.       F, L : out Positive'Base);
  34.    --  This procedure scans the string S setting F to be the index of the first
  35.    --  non-blank character of S and L to be the index of the last non-blank
  36.    --  character of S. Any lower case characters present in S will be folded
  37.    --  to their upper case equivalent except for character literals. If S
  38.    --  consists of entirely blanks then Constraint_Error is raised.
  39.    --
  40.    --  Note: if S is the null string, F is set to S'First, L to S'Last
  41.  
  42.    procedure Scan_Sign
  43.      (Str   : String;
  44.       Ptr   : access Positive'Base;
  45.       Max   : Positive'Base;
  46.       Minus : out Boolean;
  47.       Start : out Positive);
  48.    --  The Str, Ptr, Max parameters are as for the scan routines (Str is the
  49.    --  string to be scanned starting at Ptr.all, and Max is the index of the
  50.    --  last character in the string). Scan_Sign first scans out any initial
  51.    --  blanks, raising Constraint_Error if the field is all blank. It then
  52.    --  checks for and skips an initial plus or minus, requiring a non-blank
  53.    --  character to follow (Constraint_Error is raised if plus or minus
  54.    --  appears at the end of the string or with a following blank). Minus is
  55.    --  set True if a minus sign was skipped, and False otherwise. On exit
  56.    --  Ptr.all points to the character after the sign, or to the first
  57.    --  non-blank character if no sign is present. Start is set to the point
  58.    --  to the first non-blank character (sign or digit after it).
  59.    --
  60.    --  Note: if Str is null, i.e. if Max is less than Ptr, then this is a
  61.    --  special case of an all-blank string, and Ptr is unchanged, and hence
  62.    --  is greater than Max as required in this case.
  63.  
  64.    function Scan_Exponent
  65.      (Str  : String;
  66.       Ptr  : access Positive'Base;
  67.       Max  : Positive'Base;
  68.       Real : Boolean := False)
  69.       return Integer;
  70.    --  Called to scan a possible exponent. Str, Ptr, Max are as described above
  71.    --  for Scan_Sign. If Ptr.all < Max and Str (Ptr.all) = 'E' or 'e', then an
  72.    --  exponent is scanned out, with the exponent value returned in Exp, and
  73.    --  Ptr.all updated to point past the exponent. If the exponent field is
  74.    --  incorrectly formed or not present, then Ptr.all is unchanged, and the
  75.    --  returned exponent value is zero. Real indicates whether a minus sign
  76.    --  is permitted (True = permitted). Very large exponents are handled by
  77.    --  returning a suitable large value. If the base is zero, then any value
  78.    --  is allowed, and otherwise the large value will either cause underflow
  79.    --  or overflow during the scaling process which is fine.
  80.  
  81.    procedure Scan_Trailing_Blanks (Str : String; P : Positive);
  82.    --  Checks that the remainder of the field Str (P .. Str'Last) is all
  83.    --  blanks. Raises Constraint_Error if a non-blank character is found.
  84.  
  85. end System.Val_Util;
  86.